<template>
  <div class="index" v-loading="loading">
      <div class="wrap">
        <div class="service-title">
            <h2>智慧政策</h2>
            <p>Smart policy</p>
        </div>
        <div class="details-title">
            <div class="h2">{{datas.title}}</div>
            <div class="info"><p>日期：{{datas.updateTime}}</p><p>浏览 {{datas.viewed?datas.viewed:0}} 次</p></div>
        </div>
        <div class="content" v-html="datas.contents">
    
        </div>
      </div>
  </div>
</template>
<script>
import '@/assets/styles/policy-public.scss' // iboot css
import {getPolicyDetail} from '@/api/service/service'
export default {
  name: "index",
  data() {
    return {
        loading: false,
        datas:{},            //列表
    }
  },
    beforeRouteEnter (to, from, next) {
        next(vm => {
            
                //vm.beforeUrl = from.path
        })
    },
  created(){
      
  },
  mounted(){
     getPolicyDetail({id:this.getQueryString("id")}).then(res=>{
        let datas =  res.datas;
        datas.updateTime = this.renderTime(datas.updateTime)
        this.datas = datas;
         
     })
  },
  created() { 

  },
  methods:{
      getQueryString (name) { 
        let reg = `(^|&)${name}=([^&]*)(&|$)`
        let r = window.location.search.substr(1).match(reg); 
        if (r != null) return unescape(r[2]); return null; 
      },
      renderTime(date) {
        var dateee = new Date(date)
        return dateee.getFullYear()+'年'+(dateee.getMonth()+1)+'月'+dateee.getDate()+'日'
      },
  },
  
}
</script>
<style scoped>
.index{
  background: #fff;
}
.service-title{
  padding: 36px 0;
  text-align: center;
  color: #5E9F8E;
}
.service-title h2{
  font-size: 36px;
  line-height: 52px;
}
.service-title p{
  font-size: 14px;
  line-height: 24px;
  text-transform:uppercase;
}
.details-title .h2{
    font-size: 28px;
    color: #666666;
    text-align: center;
    padding: 10px 0 20px 0;
}
.details-title .info{
    text-align: center;
    padding: 10px 0;
}
.details-title .info p{
    display: inline;
    font-size: 14px;
    color:#666;
    padding: 0 16px;
}
.content{
    padding: 20px 0;
    line-height: 180%;
}
</style>
